|
LotusScript library: LSALibOCIMgr |
| Global variables |
Private InstanceS List = Variant Public InstanceSUbound = Integer Public ContextDoc = NotesDocument Public InstanceName = String
|
The motivation for this module is, to be able to use instances defined in a subfrom within a form Context or vice versa.
This is usually impossible because the scope of the global variables is restricted to either a form or a subform.
The instance manager is a central place to register instances of a class and
to retrieve them from any place. You may
- Check In objects on construction:
Function ICheckInHandle(instance As Variant, suggestedID As String) As String
Sub ICheckInOC( Instance As Variant)
- Check them out on destruction:
Sub ICheckOut( InstanceName As String)
- refer to these instances by ID from whatever context:
Function IRefer( InstanceName As String, Context As Variant) As Variant
For example:
Assume you have the following code in the form
Dim MyHandle as String
Dim MyInstance as MyClass
Set MyInstance = New MyClass(...)
MyHandle = ICheckInHandle(MyInstance , "MyUniqueSuggestedID")
MyInstance.AttribX
:
in the subform you can refere to it
Dim MyLocalInstance as New MyClass
Set MyLocalInstance = Irefer( "MyUniqueSuggestedID", Nothing)
' continue your code as if the instance would be owned by the subform form.
MyLocalInstance.AttribX
:
Usually the destructor of a class 'delete' will call
ICheckout Me
As OCIMgr is designed to work together with classes generated by the "OCards",
a tool for specification of objects and code generation, the "IcheckInOC" assumes the
instance to carry the current Notes Document in the class variable "ContextDoc" as well
as the suggested ID in "ContextInstanceId".
If your class is does not follow this conventions, you have to use the "IcheckInOCHandle"
method.
An Internal handle allways makes sure that there is a unique key by adding a time stamp with
accuracy of a second and within that a random number of 3 digits to the suggested ID.
OCIMgr is a base functionality that needs no prerequisites nor configuration.
- Author:
-
LPS EMEA
- Version:
-
2.0.0 24.MAR.2000
- History:
| 24.MAR.2000 | ESc | extracted functionality from the former Imgr
|
| 24.MAR.2000 | ESc | added a general Functionality ICheckInOC and IcheckInHandle for
Ocard instances and arbitrary objects.
|
| 02.MAY.2000 | ESc | Added robust handling for IRefer in case of invalid references to instances
|
| 08.JUN.2000 | ESc | Allow handle as parameter to ICheckOut and randomize handle below subsecond level
|
| Method Summary |
Function CodeDateTime (ProcessDate As Variant) As String |
Sub ICheckIn (Instance As Variant) |
Function ICheckInHandle (instance As Variant, suggestedID As String) As String |
Sub ICheckInOC (Instance As Variant) |
Sub ICheckOut (Instance As Variant) |
Function IRefer (Handle As String, Context As Variant) As Variant |
Sub IRename (Instance As Variant, InstanceId As String) |
ICheckInOC
Public Sub ICheckInOC(Instance As Variant)
Checks in an instance into the instance manager with the suggested ID automaticly created
This functionality is specific for instances of classes generated by Ocard, in that we make use of the fact that it carries the
member variables "Context Doc" and the "Context InstanceId" in the instance .
- Parameters:
| Instance | Variant | any ocard generated instance
|
ICheckOut
Public Sub ICheckOut(Instance As Variant)
Remove the Instance from the List as maitained by the instance manager
ICheckOut must be caled called in the destructor of a class.
HINT:
If you ommit the checkout, you risk kind of memory leeks, as the instances
are preserved until the program comes too a final end. Even system hang ups ( loops )
have been reported
Example:
call ICheckOut(Me)
Dim Handle as String
handle = IcheckInHandle( Myinstance, Myid)
:
call ICheckOut(Me)
- Parameters:
| Instance | Variant | any instance or handle to the instance
|
IRename
Public Sub IRename(Instance As Variant,InstanceId As String)
- History:
| 24.MAR.2000 | ESc | Function removed as it is nolonger used
|
IRefer
Public Function IRefer(Handle As String,Context As Variant) As Variant
Retrieves the object that is checked in corresponding to the handle. You may call with an incomplete
handle if you give a context in which the object lives and which has a creation date as a further qualifier. This
context can be a NotesDocument, NotesUIDocument or any class generated by Object cards which document
it belongs to. If the instance is not found irefer returns "nothing".
- Parameters:
| InstanceID | String | the ID of the instance to be retrieved
|
| Context | Variant | that allows to find a NotesDocument context
|
- Returns:
| Variant | object of class x as stored before
|
- History:
| 02.MAY.2000 | ESc | Added error handling in case of invalid references to instances, they yust passed into
the seach loop but instanceId is only available for OC classes.
|
ICheckInHandle
Public Function ICheckInHandle(instance As Variant,suggestedID As String) As String
Checks in the instance into the instance manager. A handle is returned which is the prefered way to
access the Instance via IRefer or ICheckout. with the suggested ID. If no ID is
suggested ("") a random ID is generated.
Example:
MyHandle = ICheckInHandle(Me,"AddrMgr") returns "ADDRMGR#24-12-1999 14:30:59.969"
where 969 is a random number
- Parameters:
| instance | Variant | Object of any class
|
| suggestedID | String | suggestion for the ID
|
- Returns:
| String | ID by which object can be accessed
|
- See also:
CodeDateTime
Private Function CodeDateTime(ProcessDate As Variant) As String
converts a date into an UDF compliant textual representation like
24-03-2000 15:32:20
If the format is invalid, it returns
00-00-0000 00:00:00
This function is the same as VCodeDateTime but kept here to make this module independent.
- Parameters:
| ProcessDate | Variant | of type date
|
- Returns:
| String | the converted textual date/ time representation
|
- See also:
ICheckIn
Public Sub ICheckIn(Instance As Variant)
Old function kept for upward compatibility
- See also:
| Top | LotusScript Doc |
| © Lotus Professional Services |
| generated on : 05-Apr-01 10:01:44 AM |